/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */
package com.ykht.proj.comsrv.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ykht.proj.comsrv.entity.VSubscribeMsg;
import com.ykht.proj.comsrv.handle.AbstractSubscribeMsgHandler;
import com.ykht.proj.comsrv.handle.SubscribeMsgHandler;
import com.ykht.proj.comsrv.mapper.VSubscribeMsgMapper;
import com.ykht.proj.comsrv.service.VSubscribeMsgService;
import com.ykht.proj.comsrv.vo.SubscribeMsg;
import com.ykht.proj.comsrv.vo.SubscribeMsgCouponExpire;
import io.reactivex.internal.subscriptions.SubscriptionHelper;
import me.chanjar.weixin.common.error.WxErrorException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 订阅消息
 *
 * @author proj code generator
 * @date 2021-06-05 15:30:54
 */
@Service
public class VSubscribeMsgServiceImpl extends ServiceImpl<VSubscribeMsgMapper, VSubscribeMsg> implements VSubscribeMsgService {
	@Resource
	private Map<String, SubscribeMsgHandler> handlerMap;

	@Override
	public void sendSubscribeMsg(SubscribeMsg subscribeMsg) throws Exception {
		SubscribeMsgHandler subscribeMsgHandler = handlerMap.get(subscribeMsg.getType());
		if (subscribeMsgHandler==null) throw new RuntimeException("实现不存在");
		//处理订阅逻辑
		subscribeMsgHandler.handle(subscribeMsg);
	}
}
